#pragma once
/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * DNS IP Version 6 Address Record Structure
 *      Represents a DNS IPv6 (AAAA) record.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
#include "stdafx.h"
using namespace System;
using namespace System::Net;

namespace Adaptive
{
	namespace Network
	{
		namespace Dns
		{
			/// <summary>
			/// Represents a DNS IPv6 (AAAA) record.
			/// </summary>
			public value struct DnsIp6AddressRecord
			{
			internal:
				/// <summary>
				/// Initializes a new instance of the class from the unmanaged record.
				/// </summary>
				/// <param name="record"> A pointer to a DNS_RECORD structure whose contents are to be copied.</param>
				DnsIp6AddressRecord(DNS_RECORD* record)
				{
					unsigned char* byteData = NULL;
					array<Byte>^	managedBytes = nullptr;

					if (record == NULL)
						IP = nullptr;
					else
					{
						byteData = (unsigned char*)&(record->Data.AAAA.Ip6Address);
						managedBytes = gcnew array<Byte>(16);
						for(int count = 0; count < 16; count++)
							managedBytes[count] = (Byte)byteData[count];

						IP = gcnew IPAddress ( managedBytes );
						delete(managedBytes);
					}
				}
			public:
				/// <summary>
				/// The IP address.
				/// </summary>
				/// <value>
				/// An <see cref="IPAddress"/> value or <b>null</b>.
				/// </value>
				IPAddress^	IP;

			private:
				/// <summary>
				/// Static constructor.
				/// </summary>
				static DnsIp6AddressRecord()
				{
				}

			};
		}
	}
}